﻿namespace HutongGames.PlayMaker
{
    using System;
    using UnityEngine;

    [Serializable]
    public class FsmTransition : IEquatable<FsmTransition>
    {
        [SerializeField]
        private byte colorIndex;
        [SerializeField]
        private HutongGames.PlayMaker.FsmEvent fsmEvent;
        [SerializeField]
        private CustomLinkConstraint linkConstraint;
        [SerializeField]
        private CustomLinkStyle linkStyle;
        [SerializeField]
        private string toState;

        public bool Equals(FsmTransition other)
        {
            if (object.ReferenceEquals(other, null))
            {
                return false;
            }
            if (object.ReferenceEquals(this, other))
            {
                return true;
            }
            if (other.toState != this.toState)
            {
                return false;
            }
            return (other.EventName == this.EventName);
        }

        public int ColorIndex
        {
            get
            {
                return this.colorIndex;
            }
            set
            {
                this.colorIndex = (byte) Mathf.Clamp(value, 0, Fsm.StateColors.Length - 1);
            }
        }

        public string EventName
        {
            get
            {
                if (!HutongGames.PlayMaker.FsmEvent.IsNullOrEmpty(this.fsmEvent))
                {
                    return this.fsmEvent.Name;
                }
                return string.Empty;
            }
        }

        public HutongGames.PlayMaker.FsmEvent FsmEvent
        {
            get
            {
                return this.fsmEvent;
            }
            set
            {
                this.fsmEvent = value;
            }
        }

        public CustomLinkConstraint LinkConstraint
        {
            get
            {
                return this.linkConstraint;
            }
            set
            {
                this.linkConstraint = value;
            }
        }

        public CustomLinkStyle LinkStyle
        {
            get
            {
                return this.linkStyle;
            }
            set
            {
                this.linkStyle = value;
            }
        }

        public string ToState
        {
            get
            {
                return this.toState;
            }
            set
            {
                this.toState = value;
            }
        }

        public enum CustomLinkConstraint : byte
        {
            LockLeft = 1,
            LockRight = 2,
            None = 0
        }

        public enum CustomLinkStyle : byte
        {
            Bezier = 1,
            Circuit = 2,
            Default = 0
        }
    }
}

